package com.uenpay.oem.ui.weipay;

import com.qiyunxin.android.http.HttpInvokeResultCode;
import com.socks.library.KLog;
import com.uenpay.im.ui.old.activity.wallet.WalletHandle;
import com.uenpay.oem.MyApplication;
import com.uenpay.oem.data.bean.UserAuthInfo;
import com.uenpay.oem.data.modelImpl.UserAuthModel;
import com.uenpay.util.net.listener.HttpOnNextListener;

/**
 * Created by PS on 2017/6/30.
 */

public class WeiPayPresenter implements WeiPayContract.Presenter {
    private final WeiPayContract.View Mview;
    private final UserAuthModel mAuthModel;
    public WeiPayPresenter(WeiPayContract.View view) {
        Mview=view;
        mAuthModel = new UserAuthModel();
    }

    @Override
    public void getUserInfo() {
        mAuthModel.userCreditVerify(new HttpOnNextListener<UserAuthInfo>() {
            @Override
            public void onError(Throwable e) {
                super.onError(e);
                KLog.d("yang ++++"+e.toString());
            }

            @Override
            public void onNext(UserAuthInfo userAuthInfo) {
                KLog.d(userAuthInfo.toString());
                Mview.showUserInfo(userAuthInfo);
                MyApplication.setUserAuthInfo(userAuthInfo);
            }
        });
    }

    @Override
    public void getBalance() {
        WalletHandle.getBalance(new WalletHandle.IGetBalanceResultListener() {
            @Override
            public void onGetBalanceResult(String balance, int status,
                                           int haspaypassword) {
                //  KLog.d(TAG, "onGetBalanceResult: balance--->" + balance + " status--->" + status);
                if (status == HttpInvokeResultCode.RESULT_OK) {
                    Mview.showBalance(balance);
                }
            }
        });
    }

    @Override
    public void onStart() {

    }

    @Override
    public void onDestroy() {

    }
}
